package edu.gyc.test;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

class MyCallable implements Callable<Integer> {

    @Override
    public Integer call() throws Exception {
        System.out.println(Thread.currentThread().getName()+"****HiCallabel");

        Thread.sleep(2000);
        return 1024;
    }
}
public class HiCallable {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<Integer> futureTask = new FutureTask<>(new MyCallable());

        Thread t = new Thread(futureTask, "AA");
        t.start();

        int r1=100;


        while (!futureTask.isDone()) {

        }
        int r2=futureTask.get();
        System.out.println(Thread.currentThread().getName()+".......");
        System.out.println("******result from callbale: "+(r1+r2));
    }
}
